package edu.xlh.travel.controller.admin;

import com.alibaba.fastjson.JSONArray;
import edu.xlh.travel.common.Result;
import edu.xlh.travel.pojo.Hotel;
import edu.xlh.travel.pojo.Orders;
import edu.xlh.travel.pojo.querypojo.QueryOrders;
import edu.xlh.travel.service.OrdersService;
import edu.xlh.travel.syslog.annontion.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;


@Controller
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    private OrdersService ordersService;

    @Log("跳转景点订单列表页面")
    @RequestMapping("/ordersList")
    public String ordersList() {
        return "admin/ordersmanage/ordersList";
    }

  /*  @RequestMapping("/findAllOrdersForAdmin")
    @ResponseBody
    public Result findAllOrdersForAdmin() {
        return ordersService.findAll();
    }*/

    @Log("查询所有的景点订单")
    @RequestMapping("/findAllOrdersForAdmin")
    @ResponseBody
    public Result findAllOrdersForAdmin(int page, int limit , HttpSession session) {
        return ordersService.findAll(page , limit , session);
    }

    /*
     * query orders by condition
     * */
    @Log("条件模糊查询景点订单")
    @RequestMapping("/QueryOrdersByCondition")
    @ResponseBody
    public Result  QueryOrdersByCondition(Integer page, Integer limit, QueryOrders queryOrders , HttpSession session) {
        return ordersService.QueryOrdersByCondition(page , limit ,queryOrders , session);
    }

    /*
     * delete order by id
     * */
    @Log("根据iid删除景点订单")
    @RequestMapping("/deleteById/{id}")
    @ResponseBody
    public Result deleteById(@PathVariable("id") String id , @RequestBody HashMap hashMap , HttpSession session) {
        return ordersService.deleteById(id , hashMap , session);
    }

    /*
     *
     * batch delete
     *  */
    @Log("批量删除景点订单")
    @RequestMapping("/batchDelete")
    @ResponseBody
    public Result batchDelete(@RequestBody JSONArray jsonArray , HttpSession session) {
        return ordersService.batchDelete(jsonArray ,session);
    }

}
